package com.ar.network;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

public class RestConnector {

	private final static String API_URL = "http://192.168.1.150:81/quiz/public/quiz/";
	private static int timeOut = NetworkUtility.DEFAULT_TIME_OUT;
    private static AsyncHttpClient client = new AsyncHttpClient();
    
    public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
        client.setTimeout(timeOut);
    	client.get(getAbsoluteUrl(url), params, responseHandler);
    }

    public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
        client.setTimeout(timeOut);
    	client.post(getAbsoluteUrl(url), params, responseHandler);
    }

    private static String getAbsoluteUrl(String relativeUrl) {
        return new String(API_URL + relativeUrl);
    }
    
    public void setTimeOut(int timeOut){
    	RestConnector.timeOut = timeOut;
    }

}
